<template>
  <div class="card">
    <div class="card-image">
      <img :src="imageUrl" :alt="title" class="header-image" />
    </div>
    <div class="card-content">
      <div class="post-meta">
        <div class="timestamp">
          <Icon name="clock" class="icon" />
          发布于 {{ formatDate(date) }}
        </div>
      </div>
      <h2 class="title">{{ title }}</h2>
      <div class="stats">
        <div class="stat-item">
          <Icon name="eye" class="icon" />
          {{ views }} 热度
        </div>
        <div class="stat-item">
          <Icon name="message-circle" class="icon" />
          {{ comments }} 评论
        </div>
        <div class="stat-item">
          <Icon name="heart" class="icon" />
          {{ likes }} 赞
        </div>
      </div>
      <div class="tags">
        <div class="tag category">
          <Icon name="folder" class="icon" />
          {{ category }}
        </div>
        <div class="tag type">
          <Icon name="bookmark" class="icon" />
          {{ type }}
        </div>
      </div>
    </div>
  </div>
</template>

<script setup>
// import { Icon } from '@iconify/vue'

const props = defineProps({
  imageUrl: {
    type: String,
    default: 'https://hebbkx1anhila5yf.public.blob.vercel-storage.com/image-XaF6z344jT8gVWmlyOavaNhyB6Yudh.png'
  },
  title: {
    type: String,
    default: 'POETIZE - SEO'
  },
  date: {
    type: String,
    default: '2025-01-04 10:52:31'
  },
  views: {
    type: Number,
    default: 1155
  },
  comments: {
    type: Number,
    default: 1
  },
  likes: {
    type: Number,
    default: 0
  },
  category: {
    type: String,
    default: 'POETIZE'
  },
  type: {
    type: String,
    default: '使用指南'
  }
})

const formatDate = (dateString) => {
  const date = new Date(dateString)
  return `${date.getFullYear()}-${String(date.getMonth() + 1).padStart(2, '0')}-${String(date.getDate()).padStart(2, '0')} ${String(date.getHours()).padStart(2, '0')}:${String(date.getMinutes()).padStart(2, '0')}:${String(date.getSeconds()).padStart(2, '0')}`
}
</script>

<style scoped>
.card {
  width: 100%;
  max-width: 400px;
  background: white;
  border-radius: 12px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.1);
  overflow: hidden;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
}

.card-image {
  width: 100%;
  height: 160px;
  overflow: hidden;
}

.header-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.card-content {
  padding: 16px;
}

.post-meta {
  display: flex;
  align-items: center;
  color: #666;
  font-size: 0.85rem;
  margin-bottom: 8px;
}

.timestamp {
  display: flex;
  align-items: center;
  gap: 4px;
}

.title {
  font-size: 1.25rem;
  font-weight: 600;
  margin: 8px 0;
  color: #333;
}

.stats {
  display: flex;
  gap: 16px;
  margin: 12px 0;
}

.stat-item {
  display: flex;
  align-items: center;
  gap: 4px;
  color: #666;
  font-size: 0.9rem;
}

.tags {
  display: flex;
  gap: 12px;
  margin-top: 12px;
}

.tag {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 0.85rem;
  background: #f5f5f5;
  color: #666;
}

.icon {
  width: 1em;
  height: 1em;
}
</style>